package com.byxy.action;

import javax.annotation.Resource;

import org.apache.struts2.ServletActionContext;

import com.byxy.aspect.MyLog;
import com.byxy.entity.Line;
import com.byxy.service.LineService;

public class LineUpdateAction {
	private Integer id; // 序号
	private String lineName; // 线路名称
	private String code; // 线路代码
	private String fromplace; // 起始地
	private String toplace; // 终点
	private int price; // 价钱
	private String remark; // 备注

	private Line line;

	@Resource
	private LineService lineService;

	public Line getLine() {
		return line;
	}

	public void setLine(Line line) {
		this.line = line;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getLineName() {
		return lineName;
	}

	public void setLineName(String lineName) {
		this.lineName = lineName;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getFromplace() {
		return fromplace;
	}

	public void setFromplace(String fromplace) {
		this.fromplace = fromplace;
	}

	public String getToplace() {
		return toplace;
	}

	public void setToplace(String toplace) {
		this.toplace = toplace;
	}

	public int getPrice() {
		return price;
	}

	public void setPrice(int price) {
		this.price = price;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	@MyLog(desc = "数据更新")
	public String update() {
		if ("POST".equalsIgnoreCase(ServletActionContext.getRequest().getMethod())) {
			line = new Line(id, lineName, code, fromplace, toplace, price, remark);
			lineService.update(line);
			return "post";
		} else {
			line = lineService.getById(id);
			return "get";
		}
	}
}
